//
//  main.cpp
//  1427
//
//  Created by 洋犀利 on 2019/9/7.
//  Copyright © 2019 洋犀利. All rights reserved.
//

#include <iostream>
using namespace std;
int numbers[101] = {0};
int much;
int now;

int main(int argc, const char * argv[]) {
    for(int i=0;i<101;i++){
        cin>>now;
        if(now!=0){
            much++;
            numbers[i] = now;
        }else{
            break;
        }
        now=0;
    }
    for(int i=much-1;i>=0;i--){
        cout<<numbers[i]<<" ";
    }
    
    return 0;
}
